package org.jeecg.modules.mall.job;

import cn.hutool.core.date.DateUtil;
import com.taobao.api.ApiException;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.util.DateUtils;
import org.jeecg.modules.mall.service.IDtkManager;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * <p>
 * 每天凌晨2点定时从大淘客网站获取最新商品信息
 * </p>
 * 9/29
 */
@Slf4j
public class DtkTask implements Job {

    @Autowired
    private IDtkManager dtkManager;
    /**
     * 定时任务执行入口
     */
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        log.info("大淘客定时任务开始运行,dateTime:{}", DateUtils.now());
        try {
            dtkManager.execute();
        } catch (ApiException e) {
            e.printStackTrace();
        }
        log.info("大淘客定时任务开始结束,dateTime:{}", DateUtils.now());
    }
}